Fix discard filter bug. Remove waypt_free() from any_route_del_wpt().
authoroliskoli <oliskoli>
Tue, 20 Feb 2007 20:59:34 +0000 (20:59 +0000)
committeroliskoli <oliskoli>
Tue, 20 Feb 2007 20:59:34 +0000 (20:59 +0000)
discard.c
position.c
route.c
smplrout.c
trackfilter.c

index 1b69c8c86311ca842e14e881e45cb8c4f43b6cbe..d8f1942c58d7c885c57c1970f6097ba7e7d83fd2 100644 (file)
--- a/discard.c
+++ b/discard.c
@@ -28,6 +28,8 @@ static char *vdopopt = NULL;
 static char *andopt = NULL;
 static double hdopf;
 static double vdopf;
+static gpsdata_type what;
+static route_head *head;
 
 static
 arglist_t fix_args[] = {
@@ -62,35 +64,43 @@ fix_process_wpt(const waypoint *wpt)
                del = delh || delv;
 
        if (del) {
-               waypt_del(waypointp);
+               switch(what) {
+                       case wptdata:
+                               waypt_del(waypointp);
+                               break;
+                       case trkdata:
+                               track_del_wpt(head, waypointp);
+                               break;
+                       case rtedata:
+                               route_del_wpt(head, waypointp);
+                               break;
+                       default:
+                               return;
+               }
                waypt_free(waypointp);
        }
 }
 
 static void
-fix_process_track(const route_head *trk)
+fix_process_head(const route_head *trk)
 {
-       waypoint * waypointp;
-       queue *elem, *tmp;
-       
-       QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) {
-               waypointp = (waypoint *)elem;
-
-               fix_process_wpt(waypointp);
-       }
+       head = (route_head *)trk;
 }
 
 static void
 fix_process(void)
 {
        // Filter waypoints.
+       what = wptdata;
        waypt_disp_all(fix_process_wpt);
 
        // Filter tracks
-       track_disp_all(fix_process_track, NULL, NULL);
+       what = trkdata;
+       track_disp_all(fix_process_head, NULL, fix_process_wpt);
        
        // And routes
-       route_disp_all(fix_process_track, NULL, NULL);
+       what = rtedata;
+       route_disp_all(fix_process_head, NULL, fix_process_wpt);
        
 }
 
index 3914963ab76daeeb3421ebe6e592aa8b4bfe1963..42247d2496066fa46f61b1a9bc6be0a4363389f7 100644 (file)
@@ -117,7 +117,6 @@ position_runqueue(queue *q, int nelems, int qtype)
                                switch (qtype) {
                                        case wptdata:
                                                waypt_del(comp[i]);
-                                               waypt_free(comp[i]);
                                                break;
                                        case trkdata:
                                                track_del_wpt(cur_rte, comp[i]);
@@ -128,6 +127,7 @@ position_runqueue(queue *q, int nelems, int qtype)
                                        default:
                                                break;
                                }
+                               waypt_free(comp[i]);
                        }
                }
        }
diff --git a/route.c b/route.c
index 39130834f3a908b6e25d2bee22ad12f1dc92ba84..d6c6a38808a096076afc9e3b3d910dab10331b88 100644 (file)
--- a/route.c
+++ b/route.c
@@ -205,7 +205,6 @@ static void
 any_route_del_wpt( route_head *rte, waypoint *wpt, int *ct)
 {
        dequeue( &wpt->Q );
-       waypt_free( wpt );
        rte->rte_waypt_ct--;
        if ( ct ) (*ct)--;
 }
index e8245219994daaad7f1bc0e376f65339c7090d35..f3088766c26486345fac435d5a5ad48f242ed396 100644 (file)
@@ -271,6 +271,7 @@ routesimple_tail( const route_head *rte )
                }
                route_del_wpt( (route_head *)(void *)rte,
                                (waypoint *)(void *)(xte_recs[i].intermed->wpt));
+               waypt_free((waypoint *)(void *)(xte_recs[i].intermed->wpt));
                
                if ( xte_recs[i].intermed->prev ) {
                        xte_recs[i].intermed->prev->next = xte_recs[i].intermed->next;
index 6b209b8cde5288ff63e58ed4defec3bce9656a47..3b3a1cbcf2faac99117335ee7ce23f6f6be36811 100644 (file)
@@ -428,6 +428,7 @@ trackfilter_merge(void)
                wpt = (waypoint *)elem;
                buff[j++] = waypt_dupe(wpt);
                track_del_wpt(track, wpt);
+               waypt_free(wpt);
            }
            if (track != master)                /* i > 0 */
                track_del_head(track);
@@ -660,8 +661,8 @@ trackfilter_split(void)
            }
            if (curr != NULL)
            {
-               wpt = waypt_dupe(buff[j]);
-               track_del_wpt(master, buff[j]);
+               wpt = buff[j];
+               track_del_wpt(master, wpt);
                track_add_wpt(curr, wpt);
                buff[j] = wpt;
            }
@@ -823,6 +824,7 @@ trackfilter_range(void)             /* returns number of track points left after filtering
                if ((wpt->creation_time < start) || (wpt->creation_time > stop))
                {
                    track_del_wpt(track, wpt);
+                   waypt_free(wpt);
                    dropped++;
                }
            }